home *** CD-ROM | disk | FTP | other *** search
/ Freelog 121 / FreelogMagazineJuilletAout2014-No121.iso / Outils / Adobe-Air / adobe-air_13.exe / [0] / setup.swf / scripts / mx / utils / NameUtil.as < prev    next >
Text File  |  2014-03-27  |  2KB  |  70 lines

  1. package mx.utils
  2. {
  3.    import flash.display.DisplayObject;
  4.    import flash.utils.getQualifiedClassName;
  5.    import mx.core.IRepeaterClient;
  6.    import mx.core.mx_internal;
  7.    
  8.    use namespace mx_internal;
  9.    
  10.    public class NameUtil
  11.    {
  12.       
  13.       mx_internal static const VERSION:String = "3.0.0.0";
  14.       
  15.       private static var counter:int = 0;
  16.        
  17.       
  18.       public function NameUtil()
  19.       {
  20.          super();
  21.       }
  22.       
  23.       public static function displayObjectToString(param1:DisplayObject) : String
  24.       {
  25.          var _loc2_:String = null;
  26.          var _loc4_:String = null;
  27.          var _loc5_:Array = null;
  28.          var _loc3_:DisplayObject = param1;
  29.          while(_loc3_ != null)
  30.          {
  31.             if(_loc3_.parent && _loc3_.stage && _loc3_.parent == _loc3_.stage)
  32.             {
  33.                break;
  34.             }
  35.             _loc4_ = _loc3_.name;
  36.             if(_loc3_ is IRepeaterClient)
  37.             {
  38.                if(_loc5_ = IRepeaterClient(_loc3_).instanceIndices)
  39.                {
  40.                   _loc4_ += "[" + _loc5_.join("][") + "]";
  41.                }
  42.             }
  43.             _loc2_ = _loc2_ == null ? _loc4_ : _loc4_ + "." + _loc2_;
  44.             _loc3_ = _loc3_.parent;
  45.          }
  46.          return _loc2_;
  47.       }
  48.       
  49.       public static function createUniqueName(param1:Object) : String
  50.       {
  51.          if(!param1)
  52.          {
  53.             return null;
  54.          }
  55.          var _loc2_:* = getQualifiedClassName(param1);
  56.          var _loc3_:int = _loc2_.indexOf("::");
  57.          if(_loc3_ != -1)
  58.          {
  59.             _loc2_ = _loc2_.substr(_loc3_ + 2);
  60.          }
  61.          var _loc4_:int;
  62.          if((_loc4_ = _loc2_.charCodeAt(_loc2_.length - 1)) >= 48 && _loc4_ <= 57)
  63.          {
  64.             _loc2_ += "_";
  65.          }
  66.          return _loc2_ + counter++;
  67.       }
  68.    }
  69. }
  70.